<div class="card">
  <div class="card-body">
  <ul class="nav nav-pills">
    <li class="nav-item text-break">
      <strong class="nav-link">$user[username]</strong>
    </li>
    <li class="nav-item">
      <a class="nav-link active" href="{MOD_URL}&op=edituser&uid=$user['uid']#user_{$user['uid']}_" onclick="jQuery('#orguser_container').load(this.href);return false;">{lang basic_message}</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="{MOD_URL}&op=edituser&do=profile&uid=$user['uid']#user_{$user['uid']}_profile" onclick="jQuery('#orguser_container').load(this.href);return false;">{lang details_information}</a>
    </li>
  </ul>
</div>
</div>
<div class="card">
<div class="card-body">
  <div id="return_edituser" style="display:none"></div>
  <form id="accountform" name="accountform" class="lyear-search-right" action="{MOD_URL}&op=edituser" method="post" onsubmit="account_submit();return false">
    <input type="hidden" name="accountedit" value="true" />
    <input type="hidden" name="uid" value="$uid" />
    <input type="hidden" name="handlekey" value="edituser" />
    <input type="hidden" name="formhash" value="{FORMHASH}" />
    <div class="row mb-3">
      <label for="email" class="col-sm-2">{lang login_email}</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" id="email" name="email" autocomplete="off" value="$user[email]" onblur="checkemail(this.id);" <!--{if !$perm}-->disabled="disabled"<!--{/if}-->>
        <p id="emailmore" style="height:1px;margin:0;">&nbsp;</p>
        <span id="chk_email" class="form-text">
          <span id="suc_email"></span><span class="help-msg"></span> {lang required_used_login_system}
        </span>
      </div>
    </div>
    <div class="row mb-3">
      <label for="username" class="col-sm-2">{lang username}</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" id="username" name="username" placeholder="{lang login_username_placeholder}" autocomplete="off" value="$user[username]" onblur="checknick(this.id);" <!--{if !$perm}-->disabled="disabled"<!--{/if}-->>
        <span id="chk_username" class="form-text">
          <span id="suc_username"></span><span class="help-msg"></span> {lang login_username_tips}
        </span>
      </div>
    </div>
    <!--{if $user[regip]}-->
    <div class="row mb-3">
      <label for="regdate" class="col-sm-2">{lang registration_time}</label>
      <div class="col-sm-10">
        <p style="margin: 0"><strong><code><!--{eval echo dgmdate($user['regdate'])}--></code></strong></p>
      </div>
    </div>
    <div class="row mb-3">
      <label for="regdate" class="col-sm-2">{lang register}IP</label>
      <div class="col-sm-10">
      <p style="margin: 0"><strong><code>$user[regip]</code></strong></p>
      </div>
    </div>
    <!--{else}-->
    <div class="row mb-3">
      <label for="regdate" class="col-sm-2">{lang add_time}</label>
      <div class="col-sm-10">
        <p style="margin: 0"><strong><code><!--{eval echo dgmdate($user['regdate'])}--></code></strong></p>
      </div>
    </div>
    <!--{/if}-->
    <div class="row mb-3">
      <label for="phone" class="col-sm-2">{lang phone_number}</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" placeholder="{lang weixin_phone_number}" id="phone" name="phone" autocomplete="off" value="$user[phone]" <!--{if !$perm}-->disabled="disabled"<!--{/if}-->>
        <span id="chk_phone" class="form-text">{lang adduser_phone_number_text}</span>
      </div>
    </div>
    <div class="row mb-3">
      <label for="weixinid" class="col-sm-2">{lang weixin}</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" placeholder="{lang user_weixin}" id="weixinid" name="weixinid" autocomplete="off" value="$user[weixinid]" <!--{if !$perm}-->disabled="disabled"<!--{/if}-->>
        <span id="chk_weixinid" class="form-text">{lang edituser_weixin_text}</span>
      </div>
    </div>
    <div class="row mb-3">
      <label for="password" class="col-sm-2">{lang user_login_password}</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="password" autocomplete="off" id="password" placeholder="{lang space_not_change_password}" <!--{if !$perm}-->disabled="disabled"<!--{/if}-->>
        <span id="chk_password" class="form-text">
          <span id="suc_password"></span>
          <span id="chk_password" class="help-msg"></span>
        </span>
      </div>
    </div>
    <div class="row mb-3">
      <label for="password2" class="col-sm-2">{lang new_password_confirm}</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" id="password2" name="password2" autocomplete="off" placeholder="{lang space_not_change_password}" <!--{if !$perm}-->disabled="disabled"<!--{/if}-->>
        <span id="chk_password2" class="form-text">
          <span id="suc_password2"></span>
          <span id="chk_password2" class="help-msg"></span>
        </span>
      </div>
    </div>
    <div class="row mb-3">
    <label for="userspace" class="col-sm-2">{lang user_set_space}</label>
      <div class="col-sm-10">
        <div class="input-group mb-3">
          <input type="text" class="form-control" id="userspace" <!--{if $_G[ 'adminid']!=1 || !$perm}-->disabled="disabled"<!--{/if}-->name="userspace" value="$userfield['userspace']" autocomplete="off">
          <span class="input-group-text">M</span>
        </div>
        <ul class="form-text">
          <li>{lang user_allocable_space}:<span class="text-danger">{eval echo ($allowallotspace == 0) ? '{lang no_limit}':formatsize($currentuserAllotspace);}</li>
          <li>{lang user_set_space_text}</li>
        </ul>
      </div>
    </div>
    <div class="row mb-3">
      <label class="col-sm-2" for="status">{lang disable_user}</label>
      <div class="col-sm-10">
        <div class="form-check form-check-inline">
          <input type="checkbox" class="form-check-input" name="status" id="status" value="1" <!--{if $user[status]}-->checked<!--{/if}--> <!--{if $_G['adminid']!=1 || !$perm}-->disabled="disabled"<!--{/if}-->>
          <label class="form-text">{lang adduser_disable_user_text}</label>
        </div>
      </div>
    </div>
    <div class="row mb-3">
      <label class="col-sm-2" for="groupid">{lang usergroup}</label>
      <div class="col-sm-10">
        <select class="form-select" name="groupid" id="groupid" <!--{if $_G[ 'adminid']!=1}--> disabled="disabled"<!--{/if}-->>
          <!--{loop $_G['cache']['usergroups'] $groupid $group}-->
          <!--{{if !in_array($groupid ,array('2','3','4','5','6','7','8'))}-->
          <option<!--{if $user[ 'groupid']==$groupid}--> selected="selected"<!--{/if}--> value="$groupid">$group['grouptitle']</option>
          <!--{/if}-->
          <!--{/loop}-->
        </select>
        <span class="form-text">{lang adduser_usergroup_text}</span>
      </div>
    </div>
    <div class="row mb-3">
      <label for="depart" class="col-sm-2">{lang department_position}&nbsp;[&nbsp;<a href="javascript:;" class="mdi mdi-plus" onclick="addorgsel()" title="{lang add_a_item}"></a>&nbsp;]</label>
      <div class="col-sm-10">
        <div id="selorg_container">
            <!--{loop $data_depart $orgid $value}-->
            <div class="btn-group p-2">
              <div class="btn-group me-2">
                <div class="btn-group org">
                  <button type="button" id="orgid_{$orgid}_Menu" class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" <!--{if !$value[ 'ismoderator']}-->disabled<!--{/if}-->>$value['depart']</button>
                  <input id="sel_orgid_{$orgid}" type="hidden" name="orgids[]" value="$orgid" onchange="selDepart(this)" />
                  <div id="orgid_{$orgid}_dropdown_menu" class="dropdown-menu org-sel-box" role="menu" aria-labelledby="orgid_{$orgid}_Menu" style="width: 300px;height: 300px;">
                    <iframe name="orgid_{$orgid}_iframe" class="org-sel-box-iframe" src="index.php?mod=system&op=orgtree&template=1&ctrlid=orgid_{$orgid}&nouser=1&moderator=1&stype=1&range=1" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" allowtransparency="true"></iframe>
                  </div>
                </div>
                <div class="btn-group job">
                  <input type="hidden" name="jobids[]" value="$value[jobid]" />
                  <!--{if $value[jobname]}-->
                  <a href="javascript:;" data-toggle="dropdown" role="button" _jobid="$value[jobid]" class="btn btn-primary dropdown-toggle jobid" <!--{if !$value[ 'ismoderator']}-->disabled<!--{/if}-->><span>$value[jobname]</span></a>
                  <!--{else}-->
                  <a href="javascript:;" data-toggle="dropdown" role="button" _jobid="0" class="btn btn-primary dropdown-toggle jobid"><span>{lang none}</span></a>
                  <!--{/if}-->
                  <ul aria-labelledby="drop-depart" role="menu" class="dropdown-menu">
                    <li>
                      <a href="javascript:;" class="dropdown-item" tabindex="-1" role="menuitem" _jobid="0" onclick="selJob(this)">{lang none}</a>
                    </li>
                    <!--{loop $value[jobs] $value1}-->
                    <li>
                      <a href="javascript:;" class="dropdown-item" tabindex="-1" role="menuitem" _jobid="$value1['jobid']" onclick="selJob(this)">$value1[name]</a>
                    </li>
                    <!--{/loop}-->
                  </ul>
                </div>
              </div>
              <!--{if $value['ismoderator']}-->
              <div class="input-group">
                <button type="button" class="btn btn-outline-danger" onclick="delDepart(this)" ttitle="{lang delete}"><i class="mdi mdi-delete"></i></button>
              </div>
              <!--{/if}-->
            </div>
            <!--{/loop}-->
            <div class="btn-group p-2" id="nav">
              <div class="btn-group me-2">
                <div class="btn-group org">
                  <button id="orgid_tpml_Menu" type="button" class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    {lang please_select_a_organization_or_department}
                  </button>
                  <input id="sel_orgid_tpml" type="hidden" name="orgids[]" value="0" onchange="selDepart(this)" />
                  <div id="orgid_tpml_dropdown_menu" class="dropdown-menu org-sel-box" style="width: 300px;height: 300px;" role="menu" aria-labelledby="orgid_tpml_Menu">
                    <iframe name="orgid_tpml_iframe" class="org-sel-box-iframe" src="index.php?mod=system&op=orgtree&template=1&ctrlid=orgid_tpml&nouser=1&moderator=1&stype=1&range=1" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" allowtransparency="true"></iframe>
                  </div>
                </div>
                <div class="btn-group job">
                  <input type="hidden" name="jobids[]" value="0" />
                  <button href="javascript:;" data-toggle="dropdown" role="button" _job="0" class="dropdown-toggle btn btn-primary jobid"><span>{lang none}</span></button>
                  <ul aria-labelledby="drop-depart" role="menu" class="dropdown-menu">
                    <li role="presentation">
                      <a href="javascript:;" tabindex="-1" role="menuitem" class="dropdown-item">{lang none}</a>
                    </li>

                  </ul>
                </div>
              </div>
                <div class="input-group">
                  <button type="button" class="btn btn-outline-danger" onclick="delDepart(this)" ttitle="{lang delete}"><i class="mdi mdi-delete"></i></button>
                </div>
            </div>
        </div>
      </div>
    </div>
    <div class="row mb-3">
      <label class="col-sm-2">{lang supervisor_position}</label>
      <div class="col-sm-10">
        <div id="upjob">
            <div class="btn-group me-2">
                <div class="btn-group org">
                  <button type="button" id="uporgid_Menu" class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">$upjob[depart]</button>
                  <input id="sel_uporgid" type="hidden" name="uporgid" value="$upjob['orgid']" onchange="selDepart(this)" />
                  <div id="uporgid_dropdown_menu" class="dropdown-menu org-sel-box" style="width: 300px;height: 300px;" role="menu" aria-labelledby="uporgid_Menu">
                    <iframe name="uporgid_iframe" class="org-sel-box-iframe" src="index.php?mod=system&op=orgtree&template=1&ctrlid=uporgid&nouser=1&stype=1&range=1&moderator=1" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" allowtransparency="true"></iframe>
                  </div>
                </div>
                <div class="btn-group job">
                    <input type="hidden" name="upjobid" value="$upjob[jobid]">
                    <!--{if $upjob}-->
                    <button data-toggle="dropdown" role="button" _jobid="$upjob[jobid]" class="dropdown-toggle btn btn-primary jobid"><span>$upjob[name]</span></button>
                    <!--{else}-->
                    <button data-toggle="dropdown" role="button" _jobid="0" class="dropdown-toggle btn btn-primary jobid"><span>{lang none}</span></button>
                    <!--{/if}-->
                    <ul aria-labelledby="drop-job" role="menu" class="dropdown-menu">
                      <li>
                        <a href="javascript:;" class="dropdown-item" tabindex="-1" role="menuitem" _jobid="0" onclick="selJob(this)">{lang none}</a>
                      </li>
                      <!--{loop $upjob[jobs] $value}-->
                      <li>
                        <a href="javascript:;" class="dropdown-item" tabindex="-1" role="menuitem" _jobid="$value['jobid']" onclick="selJob(this)">$value[name]</a>
                      </li>
                      <!--{/loop}-->
                    </ul>
                </div>
            </div>
        </div>
      </div>
    </div>
    <dl class="mb-3 d-grid">
      <input type="button" class="btn btn-primary" value="{lang save_changes}" onclick="account_submit()">
    </dl>
  </form>
</div>
</div>
<script type="text/javascript" reload="1">
location.hash = '#user_{$user['uid']}';

var orgsel_html = jQuery('#nav').html();
var lastusername = '{$user[username]}',
  lastpassword = '',
  lastemail = '{eval echo strtolower($user['email'])}',
  lastinvitecode = '',
  stmp = new Array(),
  modifypwd = true;
var pwlength = 0;
var strongpw = new Array();
var ignoreEmail = false;
  checkPwdComplexity(document.getElementById('password'), document.getElementById('password2'), 1);


function account_submit() {
  
  //判断用户名
  if(jQuery('#email').val() == '') {
    jQuery('#email').focus();
    jQuery('#email').addClass('is-invalid');
    showmessage('{lang login_email_required}', 'danger', 1000, 1);
    return false;
  }
  if(jQuery('#username').val() == '') {
    jQuery('#username').focus();
    jQuery('#username').addClass('is-invalid');
    showmessage('{lang name_will}', 'danger', 1000, 1);
    return false;
  }

  
  if((jQuery('#password').val() != '' || jQuery('#password2').val() != '') && jQuery('#password').val() != jQuery('#password2').val()){
    jQuery('#password').addClass('is-invalid');
    jQuery('#password').focus();
    return false;
  } 
  
  var flag = 0;
  jQuery('#accountform span').each(function(){
    var self=jQuery(this);
    if(self.hasClass('help-msg') && self.html() != '') {
      flag=1;
      return false;
    }
  });
  if(flag) return false;
  
  //判定微信号和手机
  var phone = jQuery('#phone').val();
  if(phone != '' && phone.match(/^\d+$/) == null) {
    jQuery('#phone').focus();
    jQuery('#phone').addClass('is-invalid');
    showmessage('{lang phone_number_illegal}', 'danger', 1000, 1);
    return false;
  }
  var weixinid = jQuery('#weixinid').val();
  if(weixinid != '' && weixinid.match(/^[a-zA-Z\d_]{5,}$/) == null) {
    jQuery('#weixinid').focus();
    jQuery('#weixinid').addClass('is-invalid');
    showmessage('{lang weixin_illegal}', 'danger', 1000, 1);
    return false;
  }
  ajaxpost('accountform', 'ajaxwaitid', 'return_edituser');
  return false;
}

function succeedhandle_edituser(url, message, values) {
  showmessage(message, 'success', 3000, 1);
};

function errorhandle_edituser(msg, values) {
  showmessage(msg, 'error', 3000, 1);
}

jQuery(document).ready(function(e) {
  jQuery('.dropdown-menu li.disabled a').on('click', function() {
    return false;
  });
});
</script>